using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using MiniProjChildrensBmiPercentiles.Models; // main class model for table properties and business logig methods 

namespace TESTminiproj
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestAgeproperty1()  // age 4.5  
        {
            Class5to7 child = new Class5to7();
            child.BirthDate = System.Convert.ToDateTime("Jan 3 2010");
            child.ReadingDate = System.Convert.ToDateTime("June 8 2014");
            double expected = 4.5;
            double actual = child.Age;
            Assert.AreEqual(expected,actual,0.04);
        }

        [TestMethod]
        public void TestAgeproperty2()  // age 5
        {
            Class5to7 child = new Class5to7();
            child.BirthDate = System.Convert.ToDateTime("april 3 2009");
            child.ReadingDate = System.Convert.ToDateTime("June 8 2014");
            double expected = 5.0;
            double actual = child.Age;
            Assert.AreEqual(expected, actual, 0.04);
        }

        [TestMethod]
        public void TestAgeproperty3()  // age 6.5
        {
            Class5to7 child = new Class5to7();
            child.BirthDate = System.Convert.ToDateTime("feb 3 2008");
            child.ReadingDate = System.Convert.ToDateTime("June 8 2014");
            double expected = 6.5;
            double actual = child.Age;
            Assert.AreEqual(expected, actual, 0.04);
        }

        [TestMethod]
        public void TestAgeproperty4()  // age 7
        {
            Class5to7 child = new Class5to7();
            child.BirthDate = System.Convert.ToDateTime("may 3 2007");
            child.ReadingDate = System.Convert.ToDateTime("June 8 2014");
            double expected = 7;
            double actual = child.Age;
            Assert.AreEqual(expected, actual, 0.04);
        }

        [TestMethod]
        public void TestAgeproperty5()  // age 7.5
        {
            Class5to7 child = new Class5to7();
            child.BirthDate = System.Convert.ToDateTime("Jan 18 2007");
            child.ReadingDate = System.Convert.ToDateTime("June 8 2014");
            double expected = 7.5;
            double actual = child.Age;
            Assert.AreEqual(expected, actual, 0.04);
        }

        [TestMethod]
        public void TestAgeproperty6()  // age 0  birth and reading dates are same - age property returns a -1
        {
            Class5to7 child = new Class5to7();
            child.BirthDate = System.Convert.ToDateTime("June 8 2014");
            child.ReadingDate = System.Convert.ToDateTime("June 8 2014");
            double expected = -1.0;
            double actual = child.Age;  // returns a -1 if birth and reading dates equal
            Assert.AreEqual(expected, actual, 0.04);
        }

        [TestMethod]
        public void TestAgeproperty7()  // minus age ie. birth greater than reading date - age property returns -1
        {                                // note DateTime type does not have negative values so is not recognizable with negative values 
            Class5to7 child = new Class5to7();
            child.BirthDate = System.Convert.ToDateTime("June 8 2015");
            child.ReadingDate = System.Convert.ToDateTime("June 8 2014");
            double expected = -1.0;
            double actual = child.Age;  // returns a -1 if birth date greater than reading date
            Assert.AreEqual(expected, actual, 0.04);
        }

        [TestMethod]
        public void TestAgeproperty8()  // test that month round up/down stays same for remainder  months 1,2,3
        {
            Class5to7 child = new Class5to7();
            child.BirthDate = System.Convert.ToDateTime("Mar 21 2013"); // check boundary value 3 as representative value
            child.ReadingDate = System.Convert.ToDateTime("June 8 2014");
            double expected = 1.0;
            double actual = child.Age;  
            Assert.AreEqual(expected, actual, 0.04);
        }

        [TestMethod]
        public void TestAgeproperty9()  // test that month round up/down stays same for remainder  months 4,5,6,7,8,9
        {
            Class5to7 child = new Class5to7();
            child.BirthDate = System.Convert.ToDateTime("September 21 2012"); // check boundary value 9 as representative value
            child.ReadingDate = System.Convert.ToDateTime("June 8 2014");
            double expected = 1.5;
            double actual = child.Age;
            Assert.AreEqual(expected, actual, 0.04);
        }

        [TestMethod]
        public void TestAgeproperty10()  // test that month round up/down stays same for remainder  months 10,11,
        {
            Class5to7 child = new Class5to7();
            child.BirthDate = System.Convert.ToDateTime("Oct 21 2012"); // check boundary value 10 as representative value
            child.ReadingDate = System.Convert.ToDateTime("June 8 2014");
            double expected = 1.5;
            double actual = child.Age;
            Assert.AreEqual(expected, actual, 0.04);
        }

        [TestMethod]
        public void TestBMIproperty1()   // note range is less than 1 to greater than 50  ** tested at just below height and weight lower  boundary
        {
            Class5to7 child = new Class5to7(); 
            child.Weight_kg = 2.0M; //  note range is greater that 2 to less than 105  ** below  lower boundary value 
            child.Height_cm = 30M; //  note range is greater than 30 to less than 190   ** below  lower boundary value 
            double expected = 0.0;
            double actual = child.BMI;
            Assert.AreEqual(expected, actual, 0.04);
        }

        [TestMethod]
        public void TestBMIproperty2()   // note range is less than 1 to greater than 50  ** tested at  height and weight lower  boundary
        {
            Class5to7 child = new Class5to7();
            child.Weight_kg = 2.5M; //  note range is greater that 2 to less than 105  ** at lower  boundary value 
            child.Height_cm = 30.5M; //  note range is greater than 30 to less than 190   ** at lower boundary value 
            double expected = 26.88;
            double actual = child.BMI;
            Assert.AreEqual(expected, actual, 0.04);
        }

        [TestMethod]
        public void TestBMIproperty3()   // note range is less than 1 to greater than 50  ** tested at just above mid point between height and weight boundaries
        {
            Class5to7 child = new Class5to7();
            child.Weight_kg = 56.0M; //  note range is greater that 2 to less than 105  ** within boundary values 
            child.Height_cm = 80.0M; //  note range is greater than 30 to less than 190   ** within boundary values 
            double expected = 87.5;
            double actual = child.BMI;
            Assert.AreEqual(expected, actual, 0.04);
        }

        [TestMethod]
        public void TestBMIproperty4()   // note range is less than 1 to greater than 50  ** tested at height and weight upper boundary
        {
            Class5to7 child = new Class5to7();
            child.Weight_kg = 104.0M; //  note range is greater that 2 to less than 105  ** upper  boundary value 
            child.Height_cm = 189.0M; //  note range is greater than 30 to less than 190   ** upper boundary value 
            double expected = 29.11;
            double actual = child.BMI;
            Assert.AreEqual(expected, actual, 0.04);
        }

        [TestMethod]
        public void TestBMIproperty8()   // note range is less than 1 to greater than 50  ** tested at above height and weight upper boundary
        {
            Class5to7 child = new Class5to7();
            child.Weight_kg = 106.0M; //  note range is greater that 2 to less than 105  ** above upper boundary value 
            child.Height_cm = 190.0M; //  note range is greater than 30 to less than 190   ** above upper boundary value 
            double expected = 0.0;
            double actual = child.BMI;
            Assert.AreEqual(expected, actual, 0.04);
        }

        [TestMethod]
        public void TestCategoryproperty1()  // category values are "under Weight", "healthy Weight", "over Weight", "obese Weight"
        {                                     // category depends on height, weight, age, gender 
            Class5to7 child = new Class5to7();
            child.Weight_kg = 10.5M; 
            child.Height_cm = 90.0M;
            child.BirthDate = System.Convert.ToDateTime("Mar 1 2009");                      // age 5 , gender F
            child.ReadingDate = System.Convert.ToDateTime("June 8 2014");
            child.Gender = "F";
            string  expected = "under Weight";
            string  actual = child.Category;
            Assert.AreEqual(expected, actual);
        }


    } // close of class unittest1

} // close of namespace

